//
//  HYGrowingUpFiles.m
//  child
//
//  Created by lijianguomac on 13-9-29.
//  Copyright (c) 2013年 lijianguomac. All rights reserved.
//

#import "HYGrowingUpFiles.h"
#import "HYGrowingUpFilesCell.h"
#import "HYGrowingUpFilesPictures.h"

@interface HYGrowingUpFiles (){
    NSMutableArray *datas;
}

@end

@implementation HYGrowingUpFiles

@synthesize growingUpFilesCellNib;

- (void)dealloc{
    [super dealloc];
    [growingUpFilesCellNib release];
    [datas release];
}
-(UINib*)statusCellNib
{
    if (growingUpFilesCellNib == nil)
    {
        [growingUpFilesCellNib release];
        growingUpFilesCellNib = [[HYGrowingUpFilesCell nib] retain];
    }
    return growingUpFilesCellNib;
}
- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        [self myInit];
    }
    return self;
}

- (void)myInit{
    
    

    
    datas = [[NSMutableArray alloc] initWithCapacity:0];
    NSDictionary *dic1 = [[NSDictionary alloc] initWithObjectsAndKeys:@"ico_wmdyj.png",@"image",
                         @"我们的一家",@"title",nil];
    [datas addObject:dic1];
    [dic1 release];
    
    NSDictionary *dic2 = [[NSDictionary alloc] initWithObjectsAndKeys:@"ico_dytsx.png",@"image",
                          @"第一天上学",@"title",nil];
    [datas addObject:dic2];
    [dic2 release];
    
    NSDictionary *dic3 = [[NSDictionary alloc] initWithObjectsAndKeys:@"ico_jcdsj",@"image",
                          @"精彩的瞬间",@"title",nil];
    [datas addObject:dic3];
    [dic3 release];
    
    NSDictionary *dic4 = [[NSDictionary alloc] initWithObjectsAndKeys:@"ico_tywj",@"image",
                          @"童言无忌",@"title",nil];
    [datas addObject:dic4];
    [dic4 release];
    
    NSDictionary *dic5 = [[NSDictionary alloc] initWithObjectsAndKeys:@"ico_wtsdw",@"image",
                          @"舞台上的我",@"title",nil];
    [datas addObject:dic5];
    [dic5 release];
    
    NSDictionary *dic6 = [[NSDictionary alloc] initWithObjectsAndKeys:@"ico_xxdgs",@"image",
                          @"喜欢的故事",@"title",nil];
    [datas addObject:dic6];
    [dic6 release];
    
    NSDictionary *dic7 = [[NSDictionary alloc] initWithObjectsAndKeys:@"ico_dydzp",@"image",
                          @"得意的作品",@"title",nil];
    [datas addObject:dic7];
    [dic7 release];
    
    NSDictionary *dic8 = [[NSDictionary alloc] initWithObjectsAndKeys:@"ico_jspy",@"image",
                          @"教师评语",@"title",nil];
    [datas addObject:dic8];
    [dic8 release];
    
    NSDictionary *dic9 = [[NSDictionary alloc] initWithObjectsAndKeys:@"ico_hldkt",@"image",
                          @"欢乐的课堂",@"title",nil];
    [datas addObject:dic9];
    [dic9 release];
    
    NSDictionary *dic10 = [[NSDictionary alloc] initWithObjectsAndKeys:@"ico_wdhpy",@"image",
                          @"我的好朋友",@"title",nil];
    [datas addObject:dic10];
    [dic10 release];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
    if ( IOS7_OR_LATER )
    {
        self.edgesForExtendedLayout = UIRectEdgeNone;
        self.extendedLayoutIncludesOpaqueBars = NO;
        self.modalPresentationCapturesStatusBarAppearance = NO;
        
    }
#endif
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
 
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    return 74;
}

- (id)cellForTableView:(UITableView *)tableView fromNib:(UINib *)nib {
    static NSString *cellID = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil) {
        NSArray *nibObjects = [nib instantiateWithOwner:nil options:nil];
        cell = [nibObjects objectAtIndex:0];
    }
    else {
        [(ETBaseCell *)cell reset];
    }
    
    return cell;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    HYGrowingUpFilesCell *cell = [self cellForTableView:tableView fromNib:self.statusCellNib];
    NSDictionary *dic = [datas objectAtIndex:indexPath.row];
    NSString *imageName = [dic objectForKey:@"image"];
    NSString *title = [dic objectForKey:@"title"];
    [cell setView:[UIImage imageNamed:imageName] title:title];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSDictionary *dic = [datas objectAtIndex:indexPath.row];
    NSString *title = [dic objectForKey:@"title"];
    HYGrowingUpFilesPictures *growingUpFilesPictures = [[HYGrowingUpFilesPictures alloc] initWithStyle:UITableViewStylePlain];
    growingUpFilesPictures.title = title;
    [self.navigationController pushViewController:growingUpFilesPictures animated:YES];
    
    [growingUpFilesPictures release];
}
/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a story board-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}

 */

@end
